 shortcut.add("Page_up",function() {
	if(document.getElementById('blanket2').style.display == "block"){
document.getElementById('blanket2').style.display = "none";
document.getElementById('popUpDiv2').style.display = "none";
}
document.getElementById('blanket').style.display = "block";
document.getElementById('popUpDiv').style.display = "block";
 

	
});
 
shortcut.add("Page_down",function() {
	
	if(document.getElementById('blanket').style.display == "block"){
document.getElementById('blanket').style.display = "none";
document.getElementById('popUpDiv').style.display = "none";
}
document.getElementById('blanket2').style.display = "block";
document.getElementById('popUpDiv2').style.display = "block";
	
});

shortcut.add("Alt+C",function() {
	
	newwindow = window.open('calculator','targetWindow','toolbar=no,location=no,top=200,status=no,menubar=no,scrollbars=yes,resizable=no,width=450,height=380');
	
});
function Close(){
	document.getElementById("popUpDiv").style.display = 'none';
	document.getElementById("blanket").style.display = 'none';
	document.getElementById("popUpDiv2").style.display = 'none';
	document.getElementById("blanket2").style.display = 'none';
}

var x;

function changecolors() {
    x = 1;
    setInterval(change, 1000);
}

function change() {
	var m=0;
	var n=0;
	var profitloss=0;
	 $.get('./countProfitLoss',function(responseJson) {
	 for(var a in responseJson){
		 m=m+(Number(responseJson[a]["lot1"])*Number(responseJson[a]["price1"]));
		 n=n+(Number(responseJson[a]["lot1"])*Number(responseJson[a]["price2"]));
		 profitloss=m-n;
	 }
	
	 if(profitloss>0){
		 color = "green";
		 document.getElementById("profit").value="Profit: "+profitloss;
		 
	 }
	 else{
		 color = "red";
		 document.getElementById("profit").value="Loss: "+profitloss;
		 	 
	 }
	 
	 });
   
    document.getElementById('profit').style.background = color;
}

function textsizer(e){

var evtobj=window.event? event : e; 
var unicode=evtobj.charCode? evtobj.charCode : evtobj.keyCode;
var actualkey=String.fromCharCode(unicode);
if (actualkey=="Page_up"){
if(document.getElementById('blanket2').style.display == "block"){
document.getElementById('blanket2').style.display = "none";
document.getElementById('popUpDiv2').style.display = "none";
}
document.getElementById('blanket').style.display = "block";
document.getElementById('popUpDiv').style.display = "block";

}
if (actualkey=="Page_down"){
if(document.getElementById('blanket').style.display == "block"){
document.getElementById('blanket').style.display = "none";
document.getElementById('popUpDiv').style.display = "none";
}
document.getElementById('blanket2').style.display = "block";
document.getElementById('popUpDiv2').style.display = "block";
}
}
document.onkeypress=textsizer;

function BuySell(parameter){

if(parameter=='buy'){
document.getElementById('blanket').style.display = "block";
document.getElementById('popUpDiv').style.display = "block";
}
if(parameter=='sell'){
document.getElementById('blanket2').style.display = "block";
document.getElementById('popUpDiv2').style.display = "block";
}
}

function displayunicode(e){
changecolors();
var unicode=e.keyCode? e.keyCode : e.charCode;

}


 $(document).ready( function() {
 done();
 
 $.get('./brokerList',function(responseJson) {
		
		var select = document.getElementById("brokerId");
		 if(responseJson!=null){      	
              for(var i=0; i<responseJson.length; i++ ){  
                			var option = document.createElement("option");
		            			option.value =responseJson[i]['userId'] ;
		            	        option.textContent = responseJson[i]['userId'];
		            		    select.appendChild(option);
					  	  }
         } 
   });
 
 
 $('#brokerId').change(function(event) {  
     var $brokerId=$("select#brokerId").val();
        $.get('./userList',{brokerName:$brokerId},function(responseJson) {   
        
         $('#userId option[value!="0"]').remove();
         
        var select = document.getElementById("userId");
        var option1 = document.createElement("option");
        select.appendChild(option1);
         if(responseJson!=null){      	
              for(var i=0; i<responseJson.length; i++ ){  
              			var option = document.createElement("option");
		            			option.value =responseJson[i]['user_ID'] ;
		            	        option.textContent = responseJson[i]['user_ID'];
		            		     select.appendChild(option);
					  }
         }  
        
        });
       
     });
 
 
 $('#brokerId1').change(function(event) {  
 	
     var $brokerId1=$("select#brokerId1").val();
   
        $.get('./userList',{brokerName:$brokerId1},function(responseJson) {   
       
         $('#userId1 option[value!="0"]').remove();
        var select = document.getElementById("userId1");
        var option1 = document.createElement("option");
        select.appendChild(option1);
         if(responseJson!=null){
              for(var i=0; i<responseJson.length; i++ ){             			 
		       			var option = document.createElement("option");
		       			option.value =responseJson[i]['user_ID'] ;
		       	        option.textContent = responseJson[i]['user_ID'];
		   			     select.appendChild(option);
					  }
         }  
    
        });
       
     });
 
 
 $.get('./brokerList',function(responseJson) {
		
		var select = document.getElementById("brokerId1");
         if(responseJson!=null){      	
              for(var i=0; i<responseJson.length; i++ ){  
     
		            			var option = document.createElement("option");
		            			option.value =responseJson[i]['userId'] ;
		            	        option.textContent = responseJson[i]['userId'];
		            		     select.appendChild(option);
					        
			
					  }
         } 
   });
 
 $('#userId').change(function(event) {  
 	
	    var $userId=$("select#userId").val();
	   	$.get('./userAccountDetail',{userName:$userId},function(responseJson) {   
	    	   
	    	   for(var a in responseJson){
					    document.getElementById("cashl").value=responseJson[a]["cashl"];
						document.getElementById("accnum").value=responseJson[a]["accno"];
						document.getElementById("marginl").value=responseJson[a]["marginl"];
						document.getElementById("marginb1").value=responseJson[a]["margin_b"];
	     
	    	   }
	       });
	    });
 
 $('#brokerId').change(function(event) {  
 	
	    var $brokerId=$("select#brokerId").val();
	     $.get('./brokerAccountDetail',{brokerName:$brokerId},function(responseJson) {   
	    	   
	    	   if(responseJson!=null){
	   			for(var a in responseJson){
	   					document.getElementById("cashlimit").value=responseJson[a]["cashl"];
	   					document.getElementById("accno").value=responseJson[a]["accno"];	
	   					document.getElementById("marginlimit").value=responseJson[a]["marginl"];
	   					document.getElementById("marginb").value=responseJson[a]["margin_b"];
	   					
	   			}
	    	   }  });
	    });
 
 $('#brokerId1').change(function(event) {  
 	
	    var $brokerId=$("select#brokerId1").val();
	     $.get('./brokerAccountDetail',{brokerName:$brokerId},function(responseJson) {   
	    	   if(responseJson!=null){
	   			for(var a in responseJson){
	   					document.getElementById("accno1").value=responseJson[a]["accno"];
	   					
	   					document.getElementById("cashl1").value=responseJson[a]["cashl"];
	   					document.getElementById("marginl1").value=responseJson[a]["marginl"];
	   					document.getElementById("marginb3").value=responseJson[a]["margin_b"];
	   			}
	   			}
	       });
	    });
 
 $('#userId1').change(function(event) {  	
	    var $userId=$("select#userId1").val();
	       $.get('./userAccountDetail',{userName:$userId},function(responseJson) {   
	    	   for(var a in responseJson){
	    	   	document.getElementById("cashl2").value=responseJson[a]["cashl"];
				document.getElementById("accnum2").value=responseJson[a]["accno"];
				document.getElementById("marginl2").value=responseJson[a]["marginl"];
				document.getElementById("marginb2").value=responseJson[a]["margin_b"];
	    	   }
	       });
	    });
 
 
 $(submit).click(function(event) { 
		/***************************************************/
		var msg=document.getElementById("msg").innerHTML;
		if($("#ptype").val()=="Intra"){
		 if($("#brokerId").val()!="" && $("#userId").val()==""  ){
			
			var e=parseInt($("#marginb").val());
			var f=parseInt($("#price").val());
	   		var g=parseInt($("#ql").val());
			var h=f*g;
			if(e>h)
				{
				msg+="Exchange has buyed "+$("#ql").val()+" lots of "+$("#symbol").val()+" for Broker "+$("#brokerId").val()+".<br/>";
				document.getElementById("msg").innerHTML=msg;

				var reqUrl="./broker/buyOrder";
				var buyJson1=JSON.stringify({ "otype":$("#otype").val(),"insname":$("#insname").val(),"symbol":$("#symbol").val(),
					"expdate":$("#expdate").val(),"qt":$("#qt").val(),"ql":$("#ql").val(),"qw":$("#qw").val(),
					"price":$("#price").val(),"ptype":$("#ptype").val(),"status":$("#status").val(),"tp":$("#tp").val(),
					"accno":$("#accno").val(),"marginl":$("#marginlimit").val(),
					"cashl":$("#cashlimit").val(),"margin_b":$("#marginb").val(),"brokeId":$("#brokerId").val(),"userId":$("#userId").val()});
						$.ajax(
							  {
							  type: "POST",
							  url: reqUrl,
							  dataType: "json",
							  contentType: 'application/json',
							  data: buyJson1,
							  success: function(html) { 			 
							    alert(html);
							  }
							});
						}
					else{
						alert("Broker "+$("#brokerId").val()+" has insufficient Margin Limit,Hence Can't buy.");
						msg+="Broker "+$("#brokerId").val()+" has insufficient margin limit hence can't buy "+$("#ql").val()+" lots of "+$("#symbol").val()+".<br/>";
						document.getElementById("msg").innerHTML=msg;
					}
			}
			else if($("#userId").val()!="" && $("#userId").val()!=null ){
			
				var a=parseInt($("#marginb1").val());
				var b=parseInt($("#price").val());
				var c=parseInt($("#ql").val());
				var d=c*b;
				if(a>d)
				{
					msg+="Exchange has buyed "+$("#ql").val()+" lots of "+$("#symbol").val()+" for User "+$("#userId").val()+".<br/>";
					document.getElementById("msg").innerHTML=msg;
					var reqUrl="./broker/buyOrder";
					var buyJson2=JSON.stringify({ "otype":$("#otype").val(),"insname":$("#insname").val(),
						"symbol":$("#symbol").val(),"expdate":$("#expdate").val(),"qt":$("#qt").val(),"ql":$("#ql").val(),
						"qw":$("#qw").val(),"price":$("#price").val(),"ptype":$("#ptype").val(),"status":$("#status").val(),
						"tp":$("#tp").val(),"userId":$("#userId").val(),"accno":$("#accnum").val(),"marginl":$("#marginl").val(),
						"cashl":$("#cashl").val(),"margin_b":$("#marginb1").val(),"brokeId":$("#brokerId").val()});	
					$.ajax(
					  {
					  type: "POST",
					  url: reqUrl,
					  dataType: "json",
					  contentType: 'application/json',
					  data: buyJson2,
					  success: function(html) { 			 
					    alert(html);
					  }
					});
				}
				else{
					alert("User "+$("#userId").val()+" has insufficient Margin Limit,Hence Can't buy.");
					msg+="User "+$("#userId").val()+" has insufficient margin limit hence can't buy "+$("#ql").val()+" lots of "+$("#symbol").val()+".<br/>";
					document.getElementById("msg").innerHTML=msg;
				}
			}
			else{
		
				msg+="Exchange has buyed "+$("#ql").val()+" lots of "+$("#symbol").val()+".<br/>";
					document.getElementById("msg").innerHTML=msg;
				var i=parseInt($("#marginbX").val());
				var j=parseInt($("#price").val());
				var k=parseInt($("#ql").val());
				var l=j*k;
				if(i>l)
				{
				var reqUrl="./broker/buyOrder";
				var buyJson3=JSON.stringify({ "otype":$("#otype").val(),"insname":$("#insname").val(),"symbol":$("#symbol").val(),
					"expdate":$("#expdate").val(),"qt":$("#qt").val(),"ql":$("#ql").val(),"qw":$("#qw").val(),"price":$("#price").val(),
					"ptype":$("#ptype").val(),"status":$("#status").val(),"tp":$("#tp").val(),"userId":$("#userId").val(),
					"accno":$("#accnoX").val(),"marginl":$("#marginX").val(),"cashl":$("#cashX").val(),"margin_b":$("#marginbX").val(),
					"brokeId":$("#brokerId").val()});	
				$.ajax(
						  {
							  type: "POST",
							  url: reqUrl,
							  dataType: "json",
							  contentType: 'application/json',
							  data: buyJson3,
							  success: function(html) { 			 
							    alert(html);
							  }
					});
				}
				else{
						alert("Exchange has insufficient Margin Limit,Hence Can't buy.");
						 msg+="Exchange has insufficient margin limit hence can't buy "+$("#ql").val()+" lots of "+$("#symbol").val()+".<br/>";
							document.getElementById("msg").innerHTML=msg;
				}
				}
			
			
			}
		
		 if($("#ptype").val()=="CarryForward")
			{
			if($("#brokerId").val()!="" && $("#userId").val()=="" ){
				msg+="Exchange has buyed "+$("#ql").val()+" lots of "+$("#symbol").val()+" for Broker "+$("#brokerId").val()+".<br/>";
				document.getElementById("msg").innerHTML=msg;
							var m=parseInt($("#cashlimit").val());
							var n=parseInt($("#price").val());
							var o=parseInt($("#ql").val());
							var p=n*o;
							if(m>p)
							{
							var reqUrl="./broker/buyOrder";
							var buyJson4=JSON.stringify({ "otype":$("#otype").val(),"insname":$("#insname").val(),
								"symbol":$("#symbol").val(),"expdate":$("#expdate").val(),"qt":$("#qt").val(),"ql":$("#ql").val(),
								"qw":$("#qw").val(),"price":$("#price").val(),"ptype":$("#ptype").val(),"status":$("#status").val(),
								"tp":$("#tp").val(),"accno":$("#accno").val(),"userId":$("#userId").val(),
								"marginl":$("#marginlimit").val(),"cashl":$("#cashlimit").val(),"margin_b":$("#marginb").val(),
								"brokeId":$("#brokerId").val()});
							$.ajax(
								  {
								  type: "POST",
								  url: reqUrl,
								  dataType: "json",
								  contentType: 'application/json',
								  data: buyJson4,
								  success: function(html) { 			 
								    alert(html);
								  }
								});
							}
							else{
								alert("Broker "+$("#brokerId").val()+"has insufficient Cash Limit,Hence Can't buy.");
								msg+="Broker "+$("#brokerId").val()+" has insufficient margin limit hence can't buy "+$("#ql").val()+" lots of "+$("#symbol").val()+".<br/>";
								document.getElementById("msg").innerHTML=msg;
							}
					
						}
	
			 else if($("#userId").val()!="" && $("#userId").val()!=null){
				 msg+="Exchange has buyed "+$("#ql").val()+" lots of "+$("#symbol").val()+" for User "+$("#userId").val()+".<br/>";
					document.getElementById("msg").innerHTML=msg;
					var i=parseInt($("#cashl").val());
					var j=parseInt($("#price").val());
					var k=parseInt($("#ql").val());
					var l=j*k;
					if(i>l)
					{
						var reqUrl="./broker/buyOrder";
						var buyJson2=JSON.stringify({ "otype":$("#otype").val(),"insname":$("#insname").val(),
							"symbol":$("#symbol").val(),"expdate":$("#expdate").val(),"qt":$("#qt").val(),"ql":$("#ql").val(),
							"qw":$("#qw").val(),"price":$("#price").val(),"ptype":$("#ptype").val(),"status":$("#status").val(),
							"tp":$("#tp").val(),"userId":$("#userId").val(),"accno":$("#accnum").val(),
							"marginl":$("#marginl").val(),"cashl":$("#cashl").val(),"margin_b":$("#marginb1").val(),
							"brokeId":$("#brokerId").val()});	
						$.ajax(
						  {
						  type: "POST",
						  url: reqUrl,
						  dataType: "json",
						  contentType: 'application/json',
						  data: buyJson2,
						  success: function(html) { 			 
						    alert(html);
						  }
						});
					}
					else{
						alert("User "+$("#userId").val()+" has insufficient Cash Limit,Hence Can't buy.");
						msg+="User "+$("#userId").val()+" has insufficient margin limit hence can't buy "+$("#ql").val()+" lots of "+$("#symbol").val()+".<br/>";
						document.getElementById("msg").innerHTML=msg;
					}
				}
			 else{
					var i=parseInt($("#cashX").val());
					var j=parseInt($("#price").val());
					var k=parseInt($("#ql").val());
					var l=j*k;
					if(i>l)
					{
						msg+="Exchange has buyed "+$("#ql").val()+" lots of "+$("#symbol").val()+".<br/>";
						document.getElementById("msg").innerHTML=msg;
						var reqUrl="./broker/buyOrder";
						var buyJson2=JSON.stringify({ "otype":$("#otype").val(),"insname":$("#insname").val(),
							"symbol":$("#symbol").val(),"expdate":$("#expdate").val(),"qt":$("#qt").val(),"ql":$("#ql").val(),
							"qw":$("#qw").val(),"price":$("#price").val(),"ptype":$("#ptype").val(),"status":$("#status").val(),
							"tp":$("#tp").val(),"accno":$("#accnoX").val(),"userId":$("#userId").val(),
							"marginl":$("#marginX").val(),"cashl":$("#cashX").val(),
							"margin_b":$("#marginbX").val(),"brokeId":$("#brokerId").val()});	
						$.ajax(
						  {
						  type: "POST",
						  url: reqUrl,
						  dataType: "json",
						  contentType: 'application/json',
						  data: buyJson2,
						  success: function(html) { 			 
						    alert(html);
						  }
						});
					}
					else{
						alert("Exchange has insufficient Cash Limit,Hence Can't buy.");
						 msg+="Exchange has insufficient margin limit hence can't buy "+$("#ql").val()+" lots of "+$("#symbol").val()+".<br/>";
							document.getElementById("msg").innerHTML=msg;
					}
			 	}		
				
							
			}
		 createBroker1();
		 RemoveUser1();
	});
 
 $(save).click(function(event) { 
		var msg=document.getElementById("msgS").innerHTML;
		
		if($("#userId1").val()!="" && $("#userId1").val()!=null){
			var m=0,totalLots=0;
			var $userId=$("#userId1").val();
			var $brokerId=$("#brokerId1").val();
		 	$.get('./broker/userBuyDetail',{userName:$userId},function(responseJson) {
				for(var a in responseJson)
				{
					if(responseJson[a]["ptype"]==$("#ptype1").val() && responseJson[a]["symbol"]==$("#symbol").val())
	 				{
	 					totalLots=Number(responseJson[a]["lot1"])-Number(responseJson[a]["lot2"]);
						if(totalLots>=Number($("#ql1").val()))
						{
	 						m=1;
	 						break;
	 					}
	 				}
				}
	 			if(m==1)
	 			{
	 				msg+="User "+$("#userId1").val()+" has sold "+$("#ql").val()+" lots of "+$("#symbol").val()+"<br/>";
	 				document.getElementById("msgS").innerHTML=msg;
	 		
					var reqUrl="./broker/sellOrder";
					var sellJson= JSON.stringify({ "otype":$("#otype1").val(),"insname":$("#insname").val(),"symbol":$("#symbol").val(),
									"expdate":$("#expdate").val(),"qt":$("#qt").val(),"ql":$("#ql1").val(),"qw":$("#qw").val(),"price":$("#sprice").val(),
									"ptype":$("#ptype1").val(),"status":$("#status1").val(),"tp":$("#tp").val(),"userId":$userId,
									"accno":$("#accnum2").val(),"marginl":$("#marginl2").val(),"cashl":$("#cashl2").val(),"margin_b":$("#marginb2").val(),
									"brokeId":$brokerId});

					$.ajax(
			  				{
			  				type: "POST",
			 				url: reqUrl,
			 				dataType: "json",
			 				contentType: 'application/json',
			  				data:sellJson,
			  				success: function(html) { 			 
			    			alert(html);
			  					}
							});
				}
				else
				{
					alert("User has not buyed sufficient lots of particular symbol");
					 msg+="User "+$("#userId1").val()+" has insufficient lots buyed hence can't sell "+$("#ql1").val()+" lots of "+$("#symbol").val()+".<br/>";
						document.getElementById("msgS").innerHTML=msg;
				}
			 });
		}
			
			else if($("#brokerId1").val()!="" && $("#userId1").val()=="" ){
				var m=0,totalLots=0;
				var $brokerId=$("#brokerId1").val();
			
				 $.get('./broker/brokerBuyDetail',{brokerName:$brokerId},function(responseJson) {
				
						
						for(var a in responseJson){
				
			 				if(responseJson[a]["ptype"]==$("#ptype1").val() && responseJson[a]["symbol"]==$("#symbol").val()){
			 					totalLots=Number(responseJson[a]["lot1"])-Number(responseJson[a]["lot2"]);
			 
									if(totalLots>=Number($("#ql1").val()))
									{	m=1;
			 							break;
			 						}
			 					}
							}
					
			 if(m==1){
				 msg+="Broker "+$("#brokerId1").val()+" has sold "+$("#ql").val()+" lots of "+$("#symbol").val()+"<br/>";
					document.getElementById("msgS").innerHTML=msg;
			
				var reqUrl="./broker/sellOrder";
				var sellJson= JSON.stringify({ "otype":$("#otype1").val(),"insname":$("#insname").val(),"symbol":$("#symbol").val(),
					"expdate":$("#expdate").val(),"qt":$("#qt").val(),"ql":$("#ql1").val(),"qw":$("#qw").val(),
					"price":$("#sprice").val(),"ptype":$("#ptype1").val(),"status":$("#status1").val(),"tp":$("#tp").val(),
					"accno":$("#accno1").val(),"marginl":$("#marginl1").val(),"cashl":$("#cashl1").val(),
					"margin_b":$("#marginb3").val(),"brokeId":$brokerId,"userId":$("#userId1").val()});
		
				$.ajax(
					  {
					  type: "POST",
					  url: reqUrl,
					  dataType: "json",
					  contentType: 'application/json',
					  data:sellJson,
					  success: function(html) { 			 
					    alert(html);
					  }
					  
					  
					});
			 }
			 else{
						alert("Broker has not buyed sufficient lots of particular symbol");
						 msg+="Broker "+$("#brokerId1").val()+" has insufficient lots buyed hence can't sell "+$("#ql1").val()+" lots of "+$("#symbol").val()+".<br/>";
							document.getElementById("msgS").innerHTML=msg;
					}
				 });

			}
			else{
				var m=0,totalLots=0;
				 $.get('./broker/exchangeBuyDetail',function(responseJson) {
						for(var a in responseJson){
						
							if(responseJson[a]["ptype"]==$("#ptype1").val() && responseJson[a]["symbol"]==$("#symbol").val()){
					
			 					totalLots=Number(responseJson[a]["lot1"])-Number(responseJson[a]["lot2"]);
								if(totalLots>=Number($("#ql1").val()))
								{	m=1;
			 						break;
			 					}
			 				}
						}
				
			 if(m==1){
				 msg+="Exchange has sold "+$("#ql").val()+" lots of "+$("#symbol").val()+"<br/>";
					document.getElementById("msgS").innerHTML=msg;
			
				var reqUrl="./broker/sellOrder";
				var sellJson= JSON.stringify({ "otype":$("#otype1").val(),"insname":$("#insname").val(),"symbol":$("#symbol").val(),
					"expdate":$("#expdate").val(),"qt":$("#qt").val(),"ql":$("#ql1").val(),"qw":$("#qw").val(),
					"price":$("#sprice").val(),"ptype":$("#ptype1").val(),"status":$("#status1").val(),"tp":$("#tp").val(),
					"accno":$("#accnoX1").val(),"marginl":$("#marginX1").val(),"cashl":$("#cashX1").val(),
					"margin_b":$("#marginbX1").val(),"brokeId":$("#brokerId1").val(),"userId":$("#userId1").val()});
			
				$.ajax(
					  {
					  type: "POST",
					  url: reqUrl,
					  dataType: "json",
					  contentType: 'application/json',
					  data:sellJson,
					  success: function(html) { 			 
					    alert(html);
					  }
					  
					  
					});
			 }
	else{
				alert("You have not buyed sufficient lots of particular symbol");
				 msg+="Exchange has insufficient lots buyed hence can't sell "+$("#ql1").val()+" lots of "+$("#symbol").val()+".<br/>";
					document.getElementById("msgS").innerHTML=msg;
			}
		 });

			}
		/**************************************************/
		createBroker2();
		removeUser2();
		});
});

function done() {
	  setTimeout( function() { 
	  updates(); 
	  done();
	  }, 200);
}
function updates() {  	
	 $.get('./AccountDetailX',function(responseJson) {
		if(responseJson!=null){
			for(var a in responseJson){
					document.getElementById("cashX").value=responseJson[a]["cashl"];
					document.getElementById("accnoX").value=responseJson[a]["accno"];
					document.getElementById("marginX").value=responseJson[a]["marginl"];
					document.getElementById("marginbX").value=responseJson[a]["margin_b"];
					
					document.getElementById("accnoX1").value=responseJson[a]["accno"];
					document.getElementById("cashX1").value=responseJson[a]["cashl"];
					document.getElementById("marginbX1").value=responseJson[a]["margin_b"];
					document.getElementById("marginX1").value=responseJson[a]["marginl"];
					
			}
			}
			});		
}  

 
		 /*******************************************************/
		 function createBroker1(){
				$.get('./brokerList',function(responseJson) {
					
					$('#brokerId option[value!="0"]').remove();
					var select = document.getElementById("brokerId");
					var option1 = document.createElement("option");
			        select.appendChild(option1);
			            if(responseJson!=null){      	
			                 for(var i=0; i<responseJson.length; i++ ){  
			       
					            			var option = document.createElement("option");
					            			option.value =responseJson[i]['userId'] ;
					            	        option.textContent = responseJson[i]['userId'];
					            		    select.appendChild(option);
								        
							
								  }
			            } 
			      });
			} 
			function RemoveUser1(){
				$('#userId option[value!="0"]').remove();
				var select = document.getElementById("userId");
				var option1 = document.createElement("option");
			    select.appendChild(option1);
			} 



function createBroker2(){
	$.get('./brokerList',function(responseJson) {
		
		$('#brokerId1 option[value!="0"]').remove();
		var select = document.getElementById("brokerId1");
		var option1 = document.createElement("option");
        select.appendChild(option1);
            if(responseJson!=null){      	
                 for(var i=0; i<responseJson.length; i++ ){  
		            			var option = document.createElement("option");
		            			option.value =responseJson[i]['userId'] ;
		            	        option.textContent = responseJson[i]['userId'];
		            		    select.appendChild(option);      
					  }
            } 
      });
} 
function removeUser2(){
	$('#userId1 option[value!="0"]').remove();
	var select = document.getElementById("userId1");
	var option1 = document.createElement("option");
    select.appendChild(option1);
} 

function oncheck(){
	if (document.form1.otype.value == "SL")
	{
	document.form1.tp.disabled = false;
	document.getElementById('status').value = 'Pending';
	}else{
	document.form1.tp.disabled = true;
	document.getElementById('status').value = 'Executed';
	}
	}
function onCheck(){
	if (document.form2.otype1.value == "SL")
	{
	document.form2.tp.disabled = false;
	document.getElementById('status1').value = 'Pending';
	}else{
	document.form2.tp.disabled = true;
	document.getElementById('status1').value = 'Executed';
	}
	}

$(function(){
    $('.source-code').each(function(index){
        var $section = $(this);
        var code =   $('#ql').updown();
        var codee =   $('#ql1').updown();
       
        // Code preview
        var $codePreview = $('<pre class="prettyprint lang-javascript"></pre>');
        $codePreview.text(code);
        $codePreview.text(codee);
        $section.html($codePreview);
        
        // Run code
        eval(code);
        eval(codee);
    });
});
